<?php /* Smarty version Smarty-3.0.8, created on 2014-01-02 18:10:00
         compiled from "E:\code\wamp\www\mapgame/tpl\main_index.html" */ ?>
<?php /*%%SmartyHeaderCode:1537952c53af80df878-68093905%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '2dc6adca1864ad24616511026caa0719f542d573' => 
    array (
      0 => 'E:\\code\\wamp\\www\\mapgame/tpl\\main_index.html',
      1 => 1388657395,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1537952c53af80df878-68093905',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<?php $_template = new Smarty_Internal_Template("tpl/header.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>
<div class="clearfix">
	<div style="width:350px" class="pull-left">
		<h2>添加游戏</h2>
		<form class="form-horizontal" role="form" action="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index'),$_smarty_tpl);?>
" method="post">
			<div class="form-group">
				<label for="game_title" class="col-sm-3 control-label">标题：</label>
				<div class="col-sm-9">
					<input type="text" name="title" id="game_title" class="form-control" placeholder="标题" value="<?php echo $_smarty_tpl->getVariable('data_return')->value['title'];?>
"/>
				</div>
			</div>
			<div class="form-group">
				<label for="game_key" class="col-sm-3 control-label">密码：</label>
				<div class="col-sm-9">
					<input type="text" name="key" id="game_key" class="form-control" placeholder="密码" value="<?php echo $_smarty_tpl->getVariable('data_return')->value['title'];?>
"/>
				</div>
			</div>		
			<div class="form-group">
				<label for="game_temple_id" class="col-sm-3 control-label">地图模板：</label>
				<div class="col-sm-9">
					<select name="temple_id" id="game_temple_id" class="form-control">
					<?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('temple_result')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>	
						<option value="<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
" ><?php echo $_smarty_tpl->tpl_vars['item']->value['title'];?>
</option>
					<?php }} ?>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<input type="submit" name="game_new" class="btn btn-info" value="添加"/>
				</div>
			</div>
		</form>
	</div>
	<div style="width:620px" class="pull-right">
		<table class="table table-striped">
			<tr>
				<th>标题</th>
				<th>日期</th>
				<th>地图模型</th>
				<th>操作</th>
			</tr>
		<?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('game_result')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>
			<tr>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['title'];?>

				</td>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['time'];?>

				</td>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['temple_id'];?>

				</td>
				<td>
					<a class="game_point_delete" game_id="<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
" href="#">清除数据</a>
					<a href="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index','game_delete_id'=>$_smarty_tpl->tpl_vars['item']->value['id']),$_smarty_tpl);?>
">删除</a>
				</td>
			</tr>
		<?php }} ?>
		</table>
	</div>
</div>
<div class="clearfix">
	<div style="width:350px" class="pull-left">
		<h2>添加地图模板</h2>
		<form class="form-horizontal" role="form" action="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index'),$_smarty_tpl);?>
" method="post">
			<div class="form-group">
				<label for="temple_title" class="col-sm-3 control-label">标题：</label>
				<div class="col-sm-9">
					<input type="text" name="title" id="temple_title" class="form-control" placeholder="标题" value="<?php echo $_smarty_tpl->getVariable('data_return')->value['title'];?>
"/>
				</div>
			</div>	
			<div class="form-group">
				<label for="temple_type" class="col-sm-3 control-label">类型：</label>
				<div class="col-sm-9">
					<select name="type" id="temple_type" class="form-control">
						<option value="1" selected="selected">民间</option>
						<option value="0" >官方</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<input type="submit" name="temple_new" class="btn btn-info" value="添加"/>
				</div>
			</div>
		</form>

	
		<table class="table table-striped">
			<tr>
				<th>标题</th>
				<th>日期</th>
				<th>类型</th>
				<th>操作</th>
			</tr>
		<?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('temple_result')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>
			<tr>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['title'];?>

				</td>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['time'];?>

				</td>
				<td>
					<?php echo $_smarty_tpl->tpl_vars['item']->value['type'];?>

				</td>
				<td>
					<a href="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index','temple_id'=>$_smarty_tpl->tpl_vars['item']->value['id']),$_smarty_tpl);?>
">编辑</a>
					<a href="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index','delete_temple_id'=>$_smarty_tpl->tpl_vars['item']->value['id']),$_smarty_tpl);?>
">删除</a>
				</td>
			</tr>
		<?php }} ?>
		</table>
	</div>
	<div class="pull-right" style="position: relative;">
	<?php if ($_smarty_tpl->getVariable('temple_id')->value){?>
		<h2>编辑地图模板：<?php echo $_smarty_tpl->getVariable('temple_item')->value['title'];?>
</h2>
		<div style="position: absolute;top:66px;right:3px;background:#fff;opacity:0.9;padding:3px; z-index: 10;">
			<div class="opera_item" id="point_new_div" style="display:none;">
				<form class="form-inline" role="form" action="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'point_new'),$_smarty_tpl);?>
" method="post">
				 	<div class="form-group">
				    	<input type="text" name="point_title" class="form-control" id="point_title" placeholder='点标题'>
				  	</div>
				  	<div class="form-group" style="width:100px;">
				    	<input type="text" name="point_lng" class="form-control" id="point_lng">
				  	</div>
				  	<div class="form-group" style="width:100px;">
				    	<input type="text" name="point_lat" class="form-control" id="point_lat">
				  	</div>
					<div class="form-group">
						<select name="point_type" id="point_type" class="form-control">
							<option value="1" selected="selected">寻宝点</option>
							<?php if (!$_smarty_tpl->getVariable('center_result')->value){?>
							<option value="0" >中心点</option>
							<?php }?>
						</select>
					</div>
					<div class="form-group">
						<input type="hidden" name="temple_id" value="<?php echo $_smarty_tpl->getVariable('temple_id')->value;?>
" id="temple_id">
						<input type="submit" name="point_new" id="point_new" class="btn btn-info" value='添加'/>
					</div>
			</div>
			<div class="opera_item" id="point_delete_div" style="display:none;">
				<input type="text" name="point_delete_title" id="point_delete_title">
				<input type="hidden" name="point_delete_id" id="point_delete_id">
				<a class="btn btn-danger" id="point_delete" href="<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'index','temple_id'=>$_smarty_tpl->getVariable('item')->value['id']),$_smarty_tpl);?>
">删除</a>
			</div>
		</div>
		<div id="map_container" style="width:620px;height: 400px;">
			地图加载中……
		</div>
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=M4Sdjd9OEZcm8pttjqUbYzvz"></script>
		<script type="text/javascript">
			var map = new BMap.Map("map_container",{mapType: BMAP_HYBRID_MAP});
			<?php if (!$_smarty_tpl->getVariable('center_result')->value){?>
				var point = new BMap.Point(119.544, 39.91539);
			<?php }else{ ?>
				var point = new BMap.Point("<?php echo $_smarty_tpl->getVariable('center_result')->value['longitude'];?>
", "<?php echo $_smarty_tpl->getVariable('center_result')->value['latitude'];?>
");
			<?php }?>
			map.centerAndZoom(point,17);// 初始化地图,设置中心点坐标和地图级别。
			map.enableScrollWheelZoom();
			map.addControl(new BMap.OverviewMapControl());    
 
			var opts = {type: BMAP_NAVIGATION_CONTROL_SMALL};
			map.addControl(new BMap.NavigationControl(opts));

			var point_delete_marker = null; //定义待删除marker变量
			//初始化星星
			<?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('point_result')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
?>
				var point = new BMap.Point(<?php echo $_smarty_tpl->tpl_vars['item']->value['longitude'];?>
,<?php echo $_smarty_tpl->tpl_vars['item']->value['latitude'];?>
);
				addMarker(point,<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
,"<?php echo $_smarty_tpl->tpl_vars['item']->value['title'];?>
",<?php echo $_smarty_tpl->tpl_vars['item']->value['type'];?>
);
			<?php }} ?>
			var i = <?php echo $_smarty_tpl->getVariable('item')->value['id']+1;?>
;
			function addMarker(point, index, label,type){  // 创建图标对象 
				i = index; 
				var icon_name = null;
				if(type==1) icon_name = "star"; 
				else  icon_name = "center"; 
				var myIcon = new BMap.Icon("tpl/images/"+icon_name+".png", new BMap.Size(24, 24), {    
					// 指定定位位置。   
					// 当标注显示在地图上时，其所指向的地理位置距离图标左上    
					// 角各偏移10像素和25像素。您可以看到在本例中该位置即是   
					// 图标中央下端的尖角位置。    
					offset: new BMap.Size(12, 12),
					label:label, 
					// 设置图片偏移。   
					// 当您需要从一幅较大的图片中截取某部分作为标注图标时，您   
					// 需要指定大图的偏移位置，此做法与css sprites技术类似。    
					//imageOffset: new BMap.Size(0, 0 - index * 25)   // 设置图片偏移    
			 	});      
				// 创建标注对象并添加到地图   
			 	var marker = new BMap.Marker(point, {icon: myIcon});  
	
			 	map.addOverlay(marker);
			 	marker.addEventListener("click", function(){
			 		$('.opera_item').hide();

			 		$('#point_delete_title').val(label);
			 		$('#point_delete_id').val(index);
			 		point_delete_marker = marker;
			 		$('#point_delete_div').show(); 	   
				 	 
				});      
			}

			
			map.addEventListener("click", function(e){
				if(e.overlay!=null) //判断覆盖物是否存在  
				{  
					return;  
				} 

				$('.opera_item').hide();

				$('#point_lng').val(e.point.lng);
				$('#point_lat').val(e.point.lat);
				$('#point_title').val(i);
				$('#point_new_div').show();	
				
			}); 
			
			$('#point_new').click(function(){
				var lng = $('#point_lng').val();
				var lat = $('#point_lat').val();
				var title = $('#point_title').val();
				var type = $('#point_type').val();
				var temple_id = $('#temple_id').val();
				
				$.ajax({
				   type: "POST",
				   url: "<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'point_new'),$_smarty_tpl);?>
",
				   data:{lng:lng,lat:lat,title:title,type:type,temple_id:temple_id},
				   success: function(point_id){
				   	 if(point_id){
				     	alert( "添加成功!");
				     	var point = new BMap.Point(lng,lat);
				     	addMarker(point,point_id,title,type);
				     }else{
				     	alert( "添加失败!");
				     }
				   }
				});
				
				$('.opera_item').hide();
				return false;
			});
			$('#point_delete').click(function(){
				var point_delete_id = $('#point_delete_id').val();
				$.ajax({
				   type: "POST",
				   url: "<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'point_delete'),$_smarty_tpl);?>
",
				   data:{point_delete_id:point_delete_id},
				   success: function(msg){
				     if(msg==1){
				     	alert( "删除成功!");
				     	map.removeOverlay(point_delete_marker);
				     }else{
				     	alert( "删除失败!");
				     }
				   }
				});
				
				$('.opera_item').hide();
				return false;
			});


			$('.game_point_delete').click(function(){
				var game_id = $(this).attr('game_id');
				$.ajax({
				   type: "POST",
				   url: "<?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['spUrl'][0][0]->__template_spUrl(array('c'=>'main','a'=>'game_point_delete'),$_smarty_tpl);?>
",
				   data:{game_id:game_id},
				   success: function(msg){
				     if(msg==1){
				     	alert( "游戏数据清除成功!");
				     }else{
				     	alert( "游戏数据清除失败!");
				     }
				   }
				});
				return false;
			});
		</script>
		
	</div>
	<?php }?>
</div>
<?php $_template = new Smarty_Internal_Template("tpl/footer.html", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>